/**
* File Name: pthread_create01.c
* Auther: Jichang
* Environment: Fedora 7 server
* use pthread_create() function.
*/
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
#include<pthread.h>

void sys_err(const char *str) 
{
	perror(str);
	exit(-1);
}

// call back function.
void *t_func(void *arg)
{
	printf("thread: pid=%d, tid=%lu\n", getpid(), pthread_self());
	return NULL;
}

int main(int argc, char *argv[])
{
	pthread_t tid;

	 // Don't create.
	printf("main: pid=%d, tid=%lu\n", getpid(), pthread_self());

	// Create thread.
	int ret = pthread_create(&tid, NULL, t_func, NULL); // call-back
	if(ret != 0) {
		perror("pthread_create error\n");
	}

	// Give son thread time to call
	sleep(1);
	
	return 0;
}

  
